<script setup lang="ts">
import { RouterView } from 'vue-router'
import router from '@/router'
import back from '@/icon/back.vue';

const goBack = () => {
  if (history.state.back === null) {
    router.replace('/')
  } else
    router.back()
}

const changeSize = () => {
  const body = document.querySelector('body')
  if (!body?.getAttribute('class')) {
    body?.setAttribute('class', 'bigSize')
  } else {
    body.removeAttribute('class')
  }

}
</script>

<template>
  <div class="page">
    <div class="head">
      <div class="back" @click="goBack">
        <back />
      </div>
      <div class="title"></div>
      <div class="font" @click="changeSize">
        <div>A</div>
      </div>
    </div>
    <div class="body">
      <RouterView></RouterView>
    </div>
  </div>
</template>

<style lang="less" scoped>
.page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

  .head {
    flex-shrink: 0;
    height: 44px;
    border-bottom: 1px solid #c8c8c8;
    box-shadow: 0 0 1px 1px #e8e8e8;
    z-index: 99;
  }

  .body {
    overflow-y: auto;
  }
}

.page {
  .head {
    display: flex;
    flex-direction: row;
    align-items: center;

    .back {
      // border: 1px solid red;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 44px;
    }

    .title {
      flex-grow: 1;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .font {
      flex-shrink: 0;
      border: 1px solid #666;
      border-radius: 50%;
      font-size: 20px;
      width: 28px;
      height: 28px;
      margin: 6px;
      margin-right: 16px;
      display: flex;
      justify-content: center;
      align-items: center;
      overflow: hidden;
      cursor: pointer;
      user-select: none;

      &:active {
        border-radius: 50%;
        overflow: hidden;
        background-color: #e8e8e8;
      }
    }
  }
}
</style>
